#include<math.h>
#include<stdio.h>

double Borwein( int numIteracoes ){
    int i;
    double a, y, aux;

    aux = sqrt(2);
    a = 6 - 4 * aux;
    y = aux - 1;

    for( i = 0; i < numIteracoes; i++ ){
        aux = sqrt( sqrt ( ( 1 - pow( y, 4 ) ) ) );
        y = ( 1 - aux ) / ( 1 + aux );

        aux = pow( 2, 2 * i + 3 );
        if(isinf(aux)){
            aux = 0;
        }
        a = a * pow( ( 1 + y ), 4 ) - aux  * y * ( 1 + y + pow( y, 2 ) );
    }

    return (double)1.0 / a;
}

int main(){
    printf( "%lf", Borwein( 1000000 ) );
    return 0;
}
